﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chinaer.Model.Common;
using Chinaer.Core.Helper;

namespace Chinaer.Bll
{
    public class AdministratorLoginDetail : Repository, IBll.IAdministratorLoginDetail
    {
        private static AdministratorLoginDetail _administratorCaoZuo = null;
        public static AdministratorLoginDetail Instance
        {
            get
            {
                if (_administratorCaoZuo == null)
                {
                    _administratorCaoZuo = new AdministratorLoginDetail();
                }
                return _administratorCaoZuo;
            }
            set
            {
                _administratorCaoZuo = value;
            }
        }
        private Chinaer.IDao.IAdministratorLoginDetailDAO administratorLoginDetailDAO = new Chinaer.Dao.AdministratorLoginDetailDAO();
        public JsonResult Add(DTO.AdministratorLoginDetailDTO t)
        {
            if (t.CheckIsNull().Success == false)
            {
                return t.CheckIsNull();
            }
            JsonResult jsonResult = new JsonResult();
            Model.Entities.Model_AdministratorLoginDetail model_AdministratorLoginDetail = new Model.Entities.Model_AdministratorLoginDetail();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(t, model_AdministratorLoginDetail);
            if (string.IsNullOrEmpty(model_AdministratorLoginDetail.ID) || model_AdministratorLoginDetail.ID.Trim() == "")
            {
                model_AdministratorLoginDetail.ID = Chinaer.Core.Helper.GenerateIDHelper.GenerateID();
            }
            jsonResult.Success = administratorLoginDetailDAO.Add(model_AdministratorLoginDetail);
            return jsonResult;
        }

        public JsonResult Delete(DTO.AdministratorLoginDetailDTO t)
        {
            if (t.CheckIsNull().Success == false)
            {
                return t.CheckIsNull();
            }
            JsonResult jsonResult = new JsonResult();
            Model.Entities.Model_AdministratorLoginDetail model_AdministratorLoginDetail = new Model.Entities.Model_AdministratorLoginDetail();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(t, model_AdministratorLoginDetail);
            jsonResult.Success = administratorLoginDetailDAO.Delete(model_AdministratorLoginDetail);
            return jsonResult;
        }

        public JsonResult Delete(string id)
        {
            JsonResult jsonResult = new JsonResult();
            jsonResult.Success = administratorLoginDetailDAO.Delete(id);
            return jsonResult;
        }

        public JsonResult Update(DTO.AdministratorLoginDetailDTO t)
        {
            if (t.CheckIsNull().Success == false)
            {
                return t.CheckIsNull();
            }
            JsonResult jsonResult = new JsonResult();
            Model.Entities.Model_AdministratorLoginDetail model_AdministratorLoginDetail = new Model.Entities.Model_AdministratorLoginDetail();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(t, model_AdministratorLoginDetail);
            jsonResult.Success = administratorLoginDetailDAO.Update(model_AdministratorLoginDetail);
            return jsonResult;
        }

        public DTO.AdministratorLoginDetailDTO GetByID(string id)
        {
            Model.Entities.Model_AdministratorLoginDetail model_AdministratorLoginDetail = new Model.Entities.Model_AdministratorLoginDetail();
            model_AdministratorLoginDetail = administratorLoginDetailDAO.GetByID(id);
            DTO.AdministratorLoginDetailDTO administratorLoginDetailDTO = new DTO.AdministratorLoginDetailDTO();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(model_AdministratorLoginDetail, administratorLoginDetailDTO);
            return administratorLoginDetailDTO;
        }
    }
}
